#include <bits/stdc++.h>
#define int long long

using namespace std;

int n, m, L, V, d[100005], v[100005], a[100005], p[100005], pre[1000005], pr[100005], ba[100005], cnt, ans = 0x3f3f3f3f;
bool ch[100005];
int up(double x)
{
    return (int)(x + 0.99);
}
int before(double x)
{
    int p = up(x);
    p--;
    if (p < 0) p = 0;
    return pre[p];
}
int after(double x)
{
    int p = (int)x;
    return pre[p] + 1;
}
int after(int x)
{
    x--;
    if (x < 0) x = 0;
    return pre[x] + 1;
}
void dfs(int pt, int cnt)
{
    if (pt > m)
    {
        bool bi = 1;
        for (int i = 1; i <= n; i++)
        {
            if (chi[i])
            {
                b[i] = 0;
                break;
            }
        }
        if (bi) ans = min(ans, m - cnt);
    }
    dfs(pt + 1, cnt);
    vector<int> vt;
    for (int i = 1; i <= n; i++)
    {
        if (!ch[i]) continue;
        if (pr[i] <= pt && pt <= ba[i])
        {
            vt.push_back(i); ch[i] = 0;
        }
    }
    dfs(pt + 1, cnt + 1);
    for (i : vt) ch[i] = 1;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while (t--)
    {
        cnt = 0;
        memset(ch, 0, sizeof(ch));
        memset(pre, 0, sizeof(pre));
        ans = 0x3f3f3f3f;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; i++) cin >> p[i];
        for (int i = 0, j = 1; i <= L; i++)
        {
            if (i > 0) pre[i] = pre[i - 1];
            if (j <= m && p[j] == i)
            {
                pre[i]++;
                j++;
            }
        }
        //for (int i = 0; i <= L; i++) cout << pre[i] << ' ';
        //cout << endl;
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == 0)
            {
                if (v[i] > V) pr[i] = after(d[i]), ba[i] = m;
                else pr[i] = 0, ba[i] = 0;
            }
            else
            {
                double beg = d[i] + double(V * V - v[i] * v[i]) / double(2 * a[i]);
                if (a[i] > 0)
                {
                    if (beg < d[i]) pr[i] = after(d[i]), ba[i] = m;
                    else if (beg < L)
                    {
                        if (after(beg) >= m) pr[i] = 0, ba[i] = 0;
                        else pr[i] = after(beg), ba[i] = m;
                    }
                    else pr[i] = 0, ba[i] = 0;
                }
                else
                {
                    //double en = d[i] + double(-v[i] * v[i]) / double(2 * a[i]);
                    if (beg > L) pr[i] = after(d[i]), ba[i] = m;
                    else if (beg > d[i])
                    {
                        if (before(beg) == 0) pr[i] = 0, ba[i] = 0;
                        else pr[i] = after(d[i]), ba[i] = before(beg);
                    }
                    else pr[i] = 0, ba[i] = 0;
                }
            }
            if (pr[i] != 0 && ba[i] != 0)
            {
                if (pr[i] > m || ba[i] < 1 || pr[i] > ba[i]) pr[i] = 0, ba[i] = 0;
                else ch[i] = 1, cnt++;
            }
            //cout << pr[i] << ' ' << ba[i] << endl;
        }
        dfs(1, 0);
        cout << cnt << ' ' << ans << endl;
    }
    return 0;
}
